package edu.sctu.zhengsenwen.month201506.day20150615.files;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * Created by user15 on 2015/6/14.
 */
public class StreamFile {

    public StreamFile() throws FileNotFoundException {

        int count = 0;
        int countByte = 0;

        byte[] buffer = new byte[1024];


        try {

            //字节流输出
            FileInputStream fileInputStream = new FileInputStream("D://HarryPote//222.jpeg");
            FileOutputStream fileOutputStream = new FileOutputStream("D://HarryPote//12345.jpeg");


            try {
                while ((countByte = fileInputStream.read(buffer)) != -1) {

                    count += countByte;

                    fileOutputStream.write(buffer, 0, countByte);

                }

                System.out.println(count);
                try {
                    fileInputStream.close();

                    fileOutputStream.close();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


    public static void main(String[] args) {

        try {
            new StreamFile();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}
